package com.example.qingyiapp.ui.activity.fragment.fragment_FindUI.childfragment;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.qingyiapp.R;
import com.example.qingyiapp.ui.activity.fragment.fragment_FindUI.adapter.FindfragmentAdapter;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * Creadted by Met·Wang on 2019/9/17 14:13
 * Describe: NullPointerException Write
 */
public class Square extends Fragment {


    ArrayList<String> strings;

    ArrayList<Fragment> fragments;
    @BindView(R.id.find_squre_tablayout)
    TabLayout findSqureTablayout;
    @BindView(R.id.find_squre_viewPager)
    ViewPager findSqureViewPager;
    Unbinder unbinder;

    FindfragmentAdapter adapter;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View inflate = inflater.inflate(R.layout.fragment_find_square, container, false);
        unbinder = ButterKnife.bind(this, inflate);

        strings = new ArrayList<>();
        fragments = new ArrayList<>();
        strings.add("等你回答");
        strings.add("精选动态");
        fragments.add(new waiyou_fragment());
        fragments.add(new dynamic_fragment());




        adapter=new FindfragmentAdapter(getChildFragmentManager(),fragments,strings);

        findSqureViewPager.setAdapter(adapter);
        findSqureTablayout.setupWithViewPager(findSqureViewPager);


        return inflate;

    }


    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }
}
